﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using DataAccessClass;

namespace ProducerBO
{
    public class SALES
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _SL_ID = -99;
        private long _C_ID =-99 ;//CUSTOMER C_ID
        private long _CLIP_ID =-99 ;//CLIPINFO CLIP_ID
        private DateTime _SL_DATE=Convert.ToDateTime( "01/01/1800");
        private bool _ISDELETED = false;
        private bool _ISACTIVE = true;

        public bool ISDELETED
        {
            get
            {
                return _ISDELETED;
            }
            set
            {
                _ISDELETED = value;
            }
        }
        public bool ISACTIVE
        {
            get
            {
                return _ISACTIVE;
            }
            set
            {
                _ISACTIVE = value;
            }
        }

        public long SL_ID
        {
            get
            {
                return _SL_ID;
            }
            set
            {
                _SL_ID = value;
            }
        }

        public long C_ID
        {
            get
            {
                return _C_ID;
            }
            set
            {
                _C_ID = value;
            }
        }

        public long CLIP_ID
        {
            get
            {
                return _CLIP_ID;
            }
            set
            {
                _CLIP_ID = value;
            }
        }
        public DateTime SL_DATE
        {
            get
            {
                return _SL_DATE;
            }
            set
            {
                _SL_DATE = value;
            }
        }

        public long SaveRecord()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@SL_ID", SL_ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@C_ID", C_ID,  DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@CLIP_ID", CLIP_ID,  DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@SL_DATE", CLIP_ID,  DbType.DateTime, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@ISDELETED", ISDELETED, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@ISACTIVE", ISACTIVE, DbType.Boolean, ParameterDirection.Input);

                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5};
                return DAC.Save("SALES_SAVE", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long SL_ID, long C_ID, long CLIP_ID, DateTime SL_DATE, bool ISDELETED, bool ISACTIVE, string andor)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@SL_ID", SL_ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@C_ID", C_ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@CLIP_ID", CLIP_ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@SL_DATE", CLIP_ID, DbType.DateTime, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@ISDELETED", ISDELETED, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@ISACTIVE", ISACTIVE, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@paraandor", andor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5,dbparam6};
                DataTable dt = DAC.Select("SALES_GET", dbparamcall);
                return dt;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }

    }
}
